User Defined Gcode (by lerman)
This page contains a proposed mechanism for user/integrator defined gcodes (and mcodes). The term user and integrator are used interchangeably for now as are gcode and mcode.
A user defined gcode is declared in the .ini file by a stanza like (subject to change)
[gcode] G31 G1 G2.2 G2 M10
The CUSTOM section will have custom gcodes and mcodes.
[CUSTOM] DIRECTORY = /path/to/directory/containing/custom/codes GCODE = 31 GCODE = 1 GCODE = 2.2 GCODE = 2 MCODE = 10
A Subroutine For User Defined Gcode
Within a user defined gcode subroutine, special named parameters are accessible.
Consider adding:
This would let the programmer write things like [#<__A> OR #<__X>] to create a mask indicating that A and X are required.
AJ: I suggest a different approach:
Additional commodity functions would be present:
The masks could look like: [#<_Mx> OR #<_My>]. The _allow_require subroutine would check the masks against the variable _mask.
Variables _a, _b, ...,_x, _y, _z would contain the values (assuming the proper mask bits were set). Also, variables __a, __b, ..., __x, __y, __Z would be non-zero if the variables were set.
This would let the user test for the presence of variables in a variety of ways.
Order Of Execution
Gcodes (and mcodes) are executed in the same order as they would have been executed if they were hard implemented gcodes or mcodes. The same rules concerning modal groups, etc are enforced.
After a user defined gcode routine determines that some parameters are missing, it should call:
O<GmissingWord> call [1] [#<missing>] [#<extra>]
In this case, 1 is the gcode number (1) and missing is a parameter with mask bits for the missing parameters. This subroutine will print messages describing the problem and then exit. A similar routine MmissingWord? should be called from mcode subroutines detecting errors.